Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[New Resource]: DataZone Project #38345

Merged
merged 17 commits into from
Jul 16, 2024
Merged

Conversation

ThomasZalewski
Copy link
Contributor

Description

This resource will allow practitioners to create DataZone Projects for a DataZone Domain via Terraform.

Relations

Relates #37423
Closes #38231

References

https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/service/datazone
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-datazone-project.html

Output from Acceptance Testing

% make testacc TESTS=TestAccDataZoneProject_basic PKG=datazone     
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.22.4 test ./internal/service/datazone/... -v -count 1 -parallel 20 -run='TestAccDataZoneProject_basic'  -timeout 360m
=== RUN   TestAccDataZoneProject_basic
=== PAUSE TestAccDataZoneProject_basic
=== CONT  TestAccDataZoneProject_basic
--- PASS: TestAccDataZoneProject_basic (27.47s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/datazone   32.386s...
make testacc TESTS=TestAccDataZoneProject_update PKG=datazone
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.22.4 test ./internal/service/datazone/... -v -count 1 -parallel 20 -run='TestAccDataZoneProject_update'  -timeout 360m
=== RUN   TestAccDataZoneProject_update
=== PAUSE TestAccDataZoneProject_update
=== CONT  TestAccDataZoneProject_update
--- PASS: TestAccDataZoneProject_update (39.00s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/datazone   43.982s
make testacc TESTS=TestAccDataZoneProject_disappears PKG=datazone
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.22.4 test ./internal/service/datazone/... -v -count 1 -parallel 20 -run='TestAccDataZoneProject_disappears'  -timeout 360m
=== RUN   TestAccDataZoneProject_disappears
=== PAUSE TestAccDataZoneProject_disappears
=== CONT  TestAccDataZoneProject_disappears
--- PASS: TestAccDataZoneProject_disappears (26.09s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/datazone   31.022s

@ThomasZalewski ThomasZalewski requested a review from a team as a code owner July 11, 2024 21:06
Copy link

Community Note

Voting for Prioritization

  • Please vote on this pull request by adding a 👍 reaction to the original post to help the community and maintainers prioritize this pull request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

For Submitters

  • Review the contribution guide relating to the type of change you are making to ensure all of the necessary steps have been taken.
  • For new resources and data sources, use skaff to generate scaffolding with comments detailing common expectations.
  • Whether or not the branch has been rebased will not impact prioritization, but doing so is always a welcome surprise.

@terraform-aws-provider terraform-aws-provider bot added documentation Introduces or discusses updates to documentation. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. generators Relates to code generators. service/datazone Issues and PRs that pertain to the datazone service. size/XL Managed by automation to categorize the size of a PR. labels Jul 11, 2024
Copy link

Thank you for your contribution! 🚀

A new usage of AWS SDK for Go V1 was detected. Please prefer AWS SDK for Go V2 for all net-new services. If this is an enhancement or bug fix to an existing AWS SDK Go V1 based resource, this comment can be safely ignored.

For additional information refer to the AWS SDK for Go Versions page in the contributor guide.

Comment on lines 163 to 172
in := &datazone.CreateProjectInput{
Name: aws.String(plan.Name.ValueString()),
DomainIdentifier: aws.String(plan.DomainId.ValueString()),
}
if !plan.Description.IsNull() {
in.Description = aws.String(plan.Description.ValueString())
}
if !plan.GlossaryTerms.IsNull() {
in.GlossaryTerms = aws.ToStringSlice(flex.ExpandFrameworkStringList(ctx, plan.GlossaryTerms))
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use flex.Expand here. AutoFlex should work in this situation, which will reduce some lines of code


var validateDomain datazone.GetDomainInput
validateDomain.Identifier = plan.DomainId.ValueStringPointer()
_, err := conn.GetDomain(ctx, &validateDomain)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should avoid doing read operations in the Create handler since the single operation here should be to create. In this case we can count on the AWS API returning an appropriate error if the domain_id is not correct when creating.

return
}

if plan.DomainId != state.DomainId {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the Plugin Framework provides builtin functions for checking equality: plan.DomainId.Equals(state.DomainId) will do equality checks for both Null and Unknown values.

We should also try to use flex.Expand here as well. internal/services/opensearchserverless/access_policy.go has a pretty good pattern for doing these equality checks, along with autoFlex.

acctest.CheckFrameworkResourceDisappears(ctx, acctest.Provider, tfdatazone.ResourceProject, resourceName),
),
ExpectNonEmptyPlan: true,
//ExpectError: regexache.MustCompile(`(AccessDeniedException)`),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cleanup

ThomasZalewski and others added 2 commits July 15, 2024 15:04
Removed aws.String

Co-authored-by: Adrian Johnson <adrian.johnson@hashicorp.com>
Co-authored-by: Adrian Johnson <adrian.johnson@hashicorp.com>
ThomasZalewski and others added 2 commits July 16, 2024 10:59
Co-authored-by: Adrian Johnson <adrian.johnson@hashicorp.com>
@johnsonaj johnsonaj added the new-resource Introduces a new resource. label Jul 16, 2024
Copy link
Contributor

@johnsonaj johnsonaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

% make testacc TESTARGS="-run=TestAccDataZoneProject_" PKG=datazone

make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.22.4 test ./internal/service/datazone/... -v -count 1 -parallel 20  -run=TestAccDataZoneProject_ -timeout 360m
--- PASS: TestAccDataZoneProject_disappears (30.21s)
--- PASS: TestAccDataZoneProject_basic (31.94s)
--- PASS: TestAccDataZoneProject_update (43.98s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/datazone	48.696s

@ThomasZalewski ThomasZalewski merged commit 1854937 into main Jul 16, 2024
55 checks passed
@ThomasZalewski ThomasZalewski deleted the f/aws-datazone-project-resource branch July 16, 2024 16:16
@github-actions github-actions bot added this to the v5.59.0 milestone Jul 16, 2024
terraform-aws-provider bot pushed a commit that referenced this pull request Jul 16, 2024
Copy link

This functionality has been released in v5.59.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Introduces or discusses updates to documentation. generators Relates to code generators. new-resource Introduces a new resource. service/datazone Issues and PRs that pertain to the datazone service. size/XL Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[New Resource]: aws_datazone_project
2 participants